package com.webservice.xmloper.visitlogcode;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;

import com.thoughtworks.xstream.XStream;
import com.webservice.command.utils.Constant;

public class VisitLogQueryResultOper {
	
	/**
	 * 解析访问日志结果xml 
	 */
	public static VisitLogReportXml parseVisitLogResultXml(String visitLogResultXml){
		VisitLogReportXml visiLogReport = null;
		XStream xs = new XStream();
		xs.processAnnotations(VisitLogReportXml.class);
		try {
			InputStream myIn = new ByteArrayInputStream(visitLogResultXml.getBytes(Constant.CHARACTER_SET));
			visiLogReport = (VisitLogReportXml) xs.fromXML(myIn);
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return visiLogReport;
	}
	
	public static String createVisitLogXmlString(VisitLogReportXml visitLogReportXml){
		XStream xs = new XStream();
		xs.processAnnotations(VisitLogReportXml.class);
		String xmlString = xs.toXML(visitLogReportXml);
		
		return xmlString;
	}
}
